<template>
	<view>
		<u-navbar title-color="#333" title-bold title-size="36" title="支付成功" :border-bottom="false"
			:background="{backgroundColor: '#ffffff'}"></u-navbar>
		
		<view class="">
			<view class="s-top text_center">
				<image class="s2" src="../../static/img/home/s2.png" mode=""></image>
				<view class="u-font-36 u-m-t-20 font_weight">
					支付成功!
				</view>
				<view class="u-m-t-20">
					感谢您的信任
				</view>
			</view>
			<view class=" dd-xx">
				<view class="">
					订单编号：{{list.order_sn}}
				</view>
				<view class="u-m-t-36">
					下单时间：：{{list.pay_time}}
				</view>
				<!-- <view class="u-m-t-36">
					支付方式：：微信支付
				</view> -->
				<view class="u-m-t-36">
					获得积分：：下单获得{{list.jifen}}积分
				</view>
			</view>
			<view class="btn13" @click="back">
				继续浏览
			</view>
			<view class="btn13" @click="lianxils" v-if="type">
				立即咨询律师
			</view>
		</view>
	</view>
</template>

<script>
	import TIM from '@/TXIM/static/IM-SDK/tim-wx.js'
	export default {
		data() {
			return {
				type:'',
				lawyer_id:'',
				list:[]
			}
		},
		onLoad(e) {
			this.list = JSON.parse(e.list)
			if(e.type=='ljzx'){
				this.type = e.type
				this.lawyer_id = e.lawyer_id
				this.getInfo()
			}
			
		},
		methods: {
			// 个人信息
			getInfo() {
				this.$api({
					url: '/getUserInfo',
					method: 'get',
					data: {
						token: uni.getStorageSync("token")
					},
				}).then(res => {
					if (res.code == 1) {
						this.$api({
							url: '/user/getImUserSign',
							method: 'post',
							data: {
								token: uni.getStorageSync("token"),
								user_id: res.data.id
							},
						}).then(res => {
							if (res.code == 1) {
								this.tim.login({
									userID: res.data.userId, //登录时的用户ID
									userSig: res.data.userSign
								}).then(function(imResponse) {
									console.log("登录结果", imResponse)
								})
							}
						})
					}
				})
			},
			
			lianxils() {
				this.$api({
					url: '/lawyer/detail',
					method: 'get',
					data: {
						token: uni.getStorageSync("token"),
						lawyer_id: this.lawyer_id
					},
				}).then(res => {
					if (res.code == 1) {
						let promise = {
							conversationID: 'C2C'+res.data.im_id,
							userProfile: {
								nick: res.data.name,
								avatar: res.data.avatar,
								userID: res.data.im_id,
							}
						}
						uni.$on('send', () => {
							uni.$emit("conversationData", promise);
						})
						uni.navigateTo({
							url: '/TXIM/pages/chat/chat'
						})
					}
				})
				
			},
			back(){
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.s-top{
		width: 750rpx;
		height: 340rpx;
		background: #FFFFFF;
		padding: 70rpx 32rpx 40rpx;
		.s2{
			width: 150rpx;
			height: 114rpx;
			margin: 0 auto;
		}
	}
	.dd-xx{
		padding: 36rpx 72rpx ;
	}
	.btn13{
		width: 608rpx;
		height: 80rpx;
		background: linear-gradient( 180deg, #FA2D2D 0%, #F40000 100%);
		border-radius: 46rpx 46rpx 46rpx 46rpx;
		font-weight: bold;
		font-size: 32rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 80rpx;
		margin: 30rpx auto;
	}
</style>
